<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css"
	href="<c:url value="/css/themes/icon.css"/>">
<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript"
	src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
<title>蒋路的呼叫页面</title>
</head>
<body>
<Style>
	.call1,.call2,.call3,.call4,.call5,#call_menu1,#call_menu3,#call_menu2,.call6{
	float:left;
	}
	.call1,.call2,.call3,.call4,.call5,.call6{
	  border:1px solid #ccc;
	}
	.call2,.call4,.call6{
	margin-left:25px;
	}
	#call_menu1{
	margin-top:5px;
	margin-left:16px;
	}
	#call_menu2{
	margin-top:15px;
	margin-left:16px;
	}
	#call_menu3{
	margin-top:15px;
	margin-left:16px;
	}
	#call_btn{
	margin-top:5px;
	height:228px;
	background-color:#d2e9ff;
	border-radius:10px;
	}

</Style>
	<script type="text/javascript">
	
	
		$(function(){
		
			$("#call_agin").linkbutton({
				onClick : function() {			
					var okCh=$("#c_chid").textbox("getText");
					$("#seeCallWin").window("close");
					$("#seechid").window({'title': "重呼人员信息"});
					$("#seechid").window("open");
					$('#seechid').panel({href:"tojl_icTopage?ieId="+okCh});					
				}
			});
			
			$("#call_next").linkbutton({
				onClick : function() {
					$("#a_yhic").textbox("setText","");
					$("#b_ygid").textbox("setText","");
					$("#c_kcid").textbox("setText","");
					$("#c_ynYz").textbox("setText","");					
					$("#seeCallWin").window("close");					
					$.messager.alert("温馨提示","操作成功");
				}
			});
									
			$("#call_exit").linkbutton({
				onClick : function() {
					$("#seeCallWin").window("close");
				}
			});
			$("#call_obey").linkbutton({
				onClick : function() {
					var pd=$("#a_yhic").textbox("getText");
					if(pd!=""){							
						$.ajax({
			                type: "Post",
			                url: "to_findbyname",
			                data: {iId:pd},
			                success: function (data) {	
			                	$.messager.confirm("确认", "病人"+data+"还未停诊是否呼叫下一位", function (r) {  
				       				 if (r) {						
				       					var chid=$("#a_yhic").textbox("getText");
				    					$("#c_chid").textbox("setText",chid);
				    					$("#a_yhic").textbox("setText","");
				    					$("#b_ygid").textbox("setText","");
				    					$("#c_kcid").textbox("setText","");
				    					$("#c_ynYz").textbox("setText","");					
				    					var info;
				    					$.ajax({
				    		                type: "Post",
				    		                url: "findminreghjhByPage",//返回挂号表中状态为空的最小的呼叫号
				    		                data: {  },
				    		                success: function (data1) {		                	
				    		                	if(data1==""|| data1==null){
				    		                		info="暂时无人挂号";
				    		                		$("#call_info").textbox("setValue",info);
				    		                	}else{
				    		                	$.ajax({
				    				                type: "Post",
				    				                url: "to_findbyIreId",//根据最小的呼叫号返回医疗卡编号
				    				                data: {callnum:data1},
				    				                success: function (data2) {				                
				    				                	$.ajax({
				    						                type: "Post",
				    						                url: "to_findbyname",//根据医疗卡编号返回用户名字
				    						                data: {iId:data2},
				    						                success: function (data3) {	
				    						               
				    						                	info="请("+data1+")号("+data3+")到(";
				    						                	$.ajax({
				    								                type: "Post",
				    								                url: "to_findbyregin",//返回最小呼叫号码的挂号对象
				    								                data: {callnum:data1},				         
				    								                success: function (data) { 
				    								                	 var strJSON = "{name:data}";
				    										             var obj = eval( "(" + strJSON + ")" );											          	
				    										             info=info+obj.name.reAdministrative +")就诊";							                			
				    										             $("#call_info").textbox("setValue",info);
				    						                        }
				    						                    });					                	 							                	
				    						                }
				    						            });
				    				                	
				    				                }
				    				            });
				    		                }}
				    		            });
				    					
				       				 }else{
				       					
				       				 }
				       			});	                	
			                }
			            });		            
					}else{
					var info;
					$.ajax({
		                type: "Post",
		                url: "findminreghjhByPage",//返回挂号表中状态为空的最小的呼叫号
		                data: {  },
		                success: function (data1) {		                	
		                	if(data1==""|| data1==null){
		                		info="暂时无人挂号";
		                		$("#call_info").textbox("setValue",info);
		                	}else{
		                	$.ajax({
				                type: "Post",
				                url: "to_findbyIreId",//根据最小的呼叫号返回医疗卡编号
				                data: {callnum:data1},
				                success: function (data2) {				                
				                	$.ajax({
						                type: "Post",
						                url: "to_findbyname",//根据医疗卡编号返回用户名字
						                data: {iId:data2},
						                success: function (data3) {	
						               
						                	info="请("+data1+")号("+data3+")到(";
						                	$.ajax({
								                type: "Post",
								                url: "to_findbyregin",//返回最小呼叫号码的挂号对象
								                data: {callnum:data1},				         
								                success: function (data) { 
								                	 var strJSON = "{name:data}";
										             var obj = eval( "(" + strJSON + ")" );											          	
										             info=info+obj.name.reAdministrative +")就诊";							                			
										             $("#call_info").textbox("setValue",info);
						                        }
						                    });					                	 							                	
						                }
						            });
				                	
				                }
				            });
		                }}
		            });
					}
				}
			});
			$("#call_forward").linkbutton({
				
				onClick : function() {
					$.ajax({
		                type: "Post",
		                url: "findminreghjhByPage",//返回最小的呼叫号
		                data: {  },
		                success: function (data) {
		                	$.ajax({
				                type: "Post",
				                url: "to_findbyregin",//返回最小的呼叫号的对象
				                data: {callnum:data},				         
				                success: function (data) {    
				                var strJSON = "{name:data}";
				                var obj = eval( "(" + strJSON + ")" );					              
							        	var oDate2 =new Date(obj.name.reDate);						        
							        	var date2y=oDate2.getFullYear();
							        	var date2m=oDate2.getMonth()+1;
							        	var date2d=oDate2.getDate();
							        	var need=date2y + '-' +date2m + '-' +date2d;
							        	$.ajax({
							                type: "Post",
							                url: "findMaxreghjhByPage",//返回最大的呼叫号
							                data: {  },
							                success: function (data) {
							                	var call=data+1;
							                	 $.ajax({
									                    type: "Post",
									                    url: "addregin",
									                    data: {reId:obj.name.reId,
									                    	   ireId:obj.name.ireId,
									                    	   reAdministrative:obj.name.reAdministrative,
									                    	   reCallNum:call,
									                    	   reDate:need,					                    	   
									                    	   reFigurePerson:obj.name.reFigurePerson,
									                    	   rePayFees:obj.name.rePayFees,
									                    	   rePhysician:obj.name.rePhysician,
									                    	   reWay:obj.name.reWay
									                    	   },			                
									                    success: function (data) {
									                    	$("#call_info").textbox("setText","");
									                    	//$("#seeCallWin").window("close");
									                    
									                    }
									                });						              	
							                }
							            });							        						               
				                }
				            });
		                }
		            });
				}
			});
			$("#call_stop").linkbutton({
				onClick : function() {
					$.ajax({
		                type: "Post",
		                url: "findminreghjhByPage",//返回挂号表中最小的呼叫号码
		                data: {  },
		                success: function (data1) {	
		                	$.ajax({
				                type: "Post",
				                url: "to_findbyregin",//返回最小呼叫号码的挂号对象
				                data: {callnum:data1},				         
				                success: function (data) {    
				                var strJSON = "{name:data}";
				                var obj = eval( "(" + strJSON + ")" );	
							        	var oDate2 =new Date(obj.name.reDate);						        
							        	var date2y=oDate2.getFullYear();
							        	var date2m=oDate2.getMonth()+1;
							        	var date2d=oDate2.getDate();
							        	var need=date2y + '-' +date2m + '-' +date2d;
					                $.ajax({
					                    type: "Post",
					                    url: "addregin",
					                    data: {reId:obj.name.reId,
					                    	   state:"结束",
					                    	   ireId:obj.name.ireId,
					                    	   reAdministrative:obj.name.reAdministrative,
					                    	   reCallNum:obj.name.reCallNum,
					                    	   reDate:need,					                    	   
					                    	   reFigurePerson:obj.name.reFigurePerson,
					                    	   rePayFees:obj.name.rePayFees,
					                    	   rePhysician:obj.name.rePhysician,
					                    	   reWay:obj.name.reWay
					                    	   },			                
					                    success: function (data) {
					                    	   $("#a_yhic").textbox("setText",obj.name.ireId);
								               var dlzh=$("#tontyiStaffId").html();	
								   			   $("#b_ygid").textbox("setText",dlzh);
								             
								   			   var YNygid=$("#b_ygid").textbox("getText");	   											
													if(YNygid!=null || YNygid!=""){
														$.ajax({
											                type: "Post",
											                url: "to_useygidToTbstaff",
											                data: {staffNo:YNygid},
											                success: function (data) {
											                    $("#c_kcid").textbox("setText",data[0].departmentNo);
											                }
											            });
													}
					                    	$("#seeCallWin").window("close");
					                    }
					                });
					               
		
						                }
						            });
		                	
		                }
		            });
					
				}
			});
			
		});
	</script>
	
	<div id="info">
	 <div class="item">
		<input id="call_info"   ReadOnly="readonly" class="easyui-textbox"  data-options=" width: 200,height:30" >
	 </div>
	<div id="call_btn">
		<div id="call_menu1">
			<div class="call1">
				<a id="call_obey" class="easyui-linkbutton"data-options="iconCls:'icon-call_obey',plain:true,width:70">顺呼</a> 
			</div>
			<div class="call2">
			    <a id="call_exit"class="easyui-linkbutton"data-options="iconCls:'icon-call_exit',plain:true,width:70">退出</a> 
			</div>	    
		</div>
		<div id="call_menu2">
			<div class="call3">
				<a id="call_stop"class="easyui-linkbutton"data-options="iconCls:'icon-call_stop',plain:true ,width:70">接诊</a>
			</div>
			<div class="call4">
			    <a id="call_forward"class="easyui-linkbutton"data-options="iconCls:'icon-call_forward',plain:true,width:70">延后</a>
			</div>			
		</div>	
		<div id="call_menu3">
			<div class="call5">
				<a id="call_next"class="easyui-linkbutton"data-options="iconCls:'icon-call_next',plain:true ,width:70">停诊</a>
			</div>	
			<div class="call6">
				<a id="call_agin"class="easyui-linkbutton"data-options="iconCls:'icon-call_next',plain:true ,width:70">重呼</a>
			</div>				
		</div>		
	</div>
	</div>
	
</body>
</html>